﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Xml.XPath;
using Maticsoft.DBUtility;
namespace DotNet.Utilities.Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            DbHelperMySQL.connectionString = "Database=sys;Data Source=localhost;User Id=root;Password=123456;pooling=false;CharSet=utf8;port=3306";
            var m = DbHelperMySQL.GetSingle("SELECT  `value` from sys_config;");

            DataTable dt = new DataTable();
            dt.TableName = "Student";
            dt.Columns.Add("Name");
            DataRow dr1 = dt.NewRow();
            dr1["Name"] = "家里人";
            DataRow dr2 = dt.NewRow();
            dr2["Name"] = "234";
            dt.Rows.Add(dr1);
            dt.Rows.Add(dr2);
            dt.WriteXml("c://123.xml", XmlWriteMode.WriteSchema);
            dt.ReadXml("c://123.xml");
            string connString = "data source=.;Initial Catalog=Test;user=sa;pwd=12344321";
            using (SqlConnection conn = new SqlConnection(connString))
            {
                conn.Open();
                SqlCommand command = new SqlCommand("SELECT Name,BornDate,Sex FROM Players FOR XML RAW('ROW'),Root('TB'),Elements", conn);
                XmlReader reader = command.ExecuteXmlReader();
                XPathDocument xpathDoc = new XPathDocument(reader); //读取数据并以XML形式返回
                conn.Close();

                //string xslPath = Server.MapPath("player.xslt"); //给XML加样式       
                //XslCompiledTransform transform = new XslCompiledTransform();
                //transform.Load(xslPath);
                //XsltArgumentList argsList = new XsltArgumentList();
                //string backGroundColor = "Tan";
                //argsList.AddParam("Color", "", backGroundColor); //给样式附值
                //transform.Transform(xpathDoc, argsList, Response.Output);

            }
        }
    }
}
